package com.jiangjiang.eshop.membership.controller;

import com.jiangjiang.eshop.membership.biz.UserDetailBiz;
import com.jiangjiang.eshop.membership.dto.UserDetailDTO;
import com.jiangjiang.eshop.membership.dto.UserDetailShowDTO;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName UserDetailController
 * @Description TODO
 * @Author jhw
 * @Date 2021/8/21 12:48
 * @Version 1.0
 **/
@Slf4j
@RestController
@RequestMapping("/user/detail")
public class UserDetailController {
    @Autowired
    private UserDetailBiz userDetailBiz;

    /**
     * 显示用户的详细信息
     * @return
     */
    @GetMapping("/showDetail/{userAccountId}")
    public UserDetailShowDTO showDetail(@PathVariable("userAccountId") Long userAccountId){
        try {
            return userDetailBiz.showDetail(userAccountId);
        }catch (Exception e){
            log.warn("UserDetailController showDetail error",e);
        }
        return null;
    }

    /**
     * 更新用户详细信息
     * @param detailDTO 用户数据
     * @return 处理结果
     */
    @PostMapping("/updateDetail")
    public Boolean updateDetail(@RequestBody UserDetailDTO detailDTO){
        try {
            return userDetailBiz.updateDetail(detailDTO);
        }catch (Exception e){
            log.warn("UserDetailController updateDetail error",e);
        }
        return false;
    }
}
